package interfaz;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import componentes.Competencia;
import componentes.Usuario;

public class GestionarRtdoFinal extends JPanel {
	private JTextField txtNombreCompetencia;
	private JLabel lblGestionarResultados; 
	private JLabel NombreCompetencia;
	private JButton btnGuardar;
	private JButton btnCancelar;
	private JLabel lblParticipanteAusente;
	private JRadioButton eq1;
	private JRadioButton eq2;
	
	/**
	 * Create the panel.
	 * @param competencia 
	 * @param pantallaInicialUserReg 
	 * @param usuarioLogueado 
	 * @param panelAnterior 
	 * @param panelPrincipal 
	 */
	public GestionarRtdoFinal(Competencia competencia, JPanel panelAnterior, JPanel panelPrincipal, Usuario usuarioLogueado, PantallaInicialUserReg pantallaInicialUserReg) {
		setBackground(new Color(255, 165, 0));
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{25, 110, 112, 51, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{29, 0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, 1.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		lblGestionarResultados = new JLabel("Gestionar Resultado");
		txtNombreCompetencia = new JTextField();
		NombreCompetencia = new JLabel("Nombre de la Competencia");
		lblGestionarResultados.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblParticipanteAusente = new JLabel("Participante Ganador");
		eq1 = new JRadioButton("Equipo 1");
		eq2 = new JRadioButton("Equipo 2");
		btnGuardar = new JButton("Guardar");
		btnCancelar = new JButton("Cancelar");
		
		inicializar(competencia,panelAnterior, panelPrincipal, usuarioLogueado, pantallaInicialUserReg);
		
		
	}
		public void inicializar(Competencia competencia, final JPanel panelAnterior, JPanel panelPrincipal, final Usuario usuarioLogueado, final PantallaInicialUserReg pantallaInicialUserReg){
		
			GridBagConstraints gbc_lblGenerarResultadosDe = new GridBagConstraints();
			gbc_lblGenerarResultadosDe.gridwidth = 4;
			gbc_lblGenerarResultadosDe.insets = new Insets(0, 0, 5, 5);
			gbc_lblGenerarResultadosDe.gridx = 1;
			gbc_lblGenerarResultadosDe.gridy = 0;
			add(lblGestionarResultados, gbc_lblGenerarResultadosDe);
					
			GridBagConstraints gbc_lblNombreCompetencia = new GridBagConstraints();
			gbc_lblNombreCompetencia.anchor = GridBagConstraints.EAST;
			gbc_lblNombreCompetencia.insets = new Insets(0, 0, 5, 5);
			gbc_lblNombreCompetencia.gridx = 1;
			gbc_lblNombreCompetencia.gridy = 1;
			add(NombreCompetencia, gbc_lblNombreCompetencia);
					
			GridBagConstraints gbc_textField = new GridBagConstraints();
			gbc_textField.anchor = GridBagConstraints.WEST;
			gbc_textField.insets = new Insets(0, 0, 5, 5);
			gbc_textField.fill = GridBagConstraints.HORIZONTAL;
			gbc_textField.gridx = 2;
			gbc_textField.gridy = 1;
			add(txtNombreCompetencia, gbc_textField);
			txtNombreCompetencia.setColumns(10);
			
			GridBagConstraints gbc_lblParticipanteAusenteEn = new GridBagConstraints();
			gbc_lblParticipanteAusenteEn.anchor = GridBagConstraints.EAST;
			gbc_lblParticipanteAusenteEn.insets = new Insets(0, 0, 5, 5);
			gbc_lblParticipanteAusenteEn.gridx = 1;
			gbc_lblParticipanteAusenteEn.gridy = 2;
			add(lblParticipanteAusente, gbc_lblParticipanteAusenteEn);
			
			eq1.setBackground(new Color(255, 165, 0));
			GridBagConstraints gbc_eq1 = new GridBagConstraints();
			gbc_eq1.insets = new Insets(0, 0, 5, 5);
			gbc_eq1.gridx = 2;
			gbc_eq1.gridy = 2;
			add(eq1, gbc_eq1);
						
			eq2.setBackground(new Color(255, 165, 0));
			GridBagConstraints gbc_eq2 = new GridBagConstraints();
			gbc_eq2.insets = new Insets(0, 0, 5, 5);
			gbc_eq2.gridx = 3;
			gbc_eq2.gridy = 2;
			add(eq2, gbc_eq2);
						
			GridBagConstraints gbc_btnAceptar = new GridBagConstraints();
			gbc_btnAceptar.insets = new Insets(0, 0, 5, 5);
			gbc_btnAceptar.gridx = 2;
			gbc_btnAceptar.gridy = 4;
			add(btnGuardar, gbc_btnAceptar);
						
			GridBagConstraints gbc_btnCancelar = new GridBagConstraints();
			gbc_btnCancelar.insets = new Insets(0, 0, 5, 5);
			gbc_btnCancelar.gridx = 3;
			gbc_btnCancelar.gridy = 4;
			add(btnCancelar, gbc_btnCancelar);

			//listener
			btnGuardar.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					setVisible(false);
					panelAnterior.setVisible(true);
				}
			});

			btnCancelar.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					setVisible(false);
					panelAnterior.setVisible(true);
				}
			});
			
	}
}
